package ControlLayer;

import java.util.ArrayList;

import DBLayer.DBCustomer;
import ModelLayer.Customer;

public class CtrCustomer {

	DBCustomer dbCust;
	Customer cust = new Customer();

	public CtrCustomer() {
		dbCust = new DBCustomer();
	}

	public ArrayList<Customer> getAll() {

		return dbCust.getAll();
	}

	public ArrayList<Customer> getAll_byType(String type) {

		return dbCust.getAll_byType(type);
	}

	public Customer find(String fname) {
		return dbCust.find(fname);
	}

	public Customer find_byID(int id) {
		return dbCust.find_byID(id);
	}

	public int delete(int sid) {
		return dbCust.delete(sid);
	}

	public int insert(int pid, String name, String address, String phoneNo,
			String email, String type) {

		Customer cust = new Customer(-1, name, address, phoneNo, email, type);

		int rc = -1;
		try {
			rc = dbCust.insert(cust);
		} catch (Exception e) {

			e.printStackTrace();
		}
		return rc;
	}

	public int update(int cid,String name, String address, String phoneNo,
			String email,  String type) {
	
		Customer cust = new Customer(cid,name,address,phoneNo,email,type);
	
		return dbCust.update(cust);

	}
}
